<template>
	<view class="detail-view">
		<view class="top-bar"><uni-navbar :fixed="true" :back="true" color="#fff" title="文章详情"></uni-navbar></view>

		<view class="detail-info" v-if="infoDetail.id">
			<view class="info-title">
				<view class="title-top">{{ infoDetail.title }}</view>
				<view class="title-btm">
					<text class="btm-name">{{ infoDetail.createByName }}</text>
					<text class="btm-time">{{ infoDetail.createTime | parseTime('{y}-{m}-{d}') }}</text>
				</view>
			</view>
			<view class="info-detail">
				<view class="overflow"><uni-parse :content="infoDetail.content"></uni-parse></view>
			</view>
		</view>

		<view class="video-box" v-if="infoDetail.videoLink"><video class="new-video" :src="infoDetail.videoLink" controls></video></view>

		<view class="uploader-add" @click="onTts">
			<image v-if="!play" src="/static/img/icon_76.png" mode="widthFix"></image>
			<image src="/static/img/icon_77.gif" v-else mode="widthFix"></image>
		</view>

		<view class="file-list" v-if="fileList.length > 0">
			<view>附件:</view>
			<view class="file-item" v-for="(item, index) in fileList" :key="index" @click="$showLine(item)">
				<view class="file-name clamp">{{ item.name }}</view>
				<view class="right-type">预览</view>
			</view>
		</view>

		<view v-if="false && dict"></view>
	</view>
</template>

<script>
import uniParse from '@/components/uni-parse/parse.vue';
import { mapState } from 'vuex';
export default {
	components: {
		uniParse
	},
	data() {
		return {
			typeList: {},
			typeMap: {},
			id: '',
			fileList: [],
			infoDetail: {},
			play: false
		};
	},
	onLoad(option) {
		this.loadLogin();
		this.id = option.id;
		this.loadData();
	},
	onHide() {
		this.$ttsOff();
	},
	onUnload() {
		this.$ttsOff();
	},
	computed: {
		...mapState(['userInfo'])
	},
	methods: {
		loadLogin() {
			if (this.userInfo.Authorization) {
			} else {
				this.$logout();
			}
		},
		loadData() {
			let url = '/wyfc/query/' + this.id;
			this.$request(url, {
				id: this.id
			}).then((res) => {
				if (!res.data) {
					return false;
				}
				this.infoDetail = res.data.wyfc;
				this.fileList = res.data.fileList;
			});
		},
		onTts() {
			let text = this.infoDetail.title;
			if (this.infoDetail.createByName) {
				text += this.infoDetail.createByName;
			}
			text += ',' + this.$parseTime(this.infoDetail.createTime, '{y}-{m}-{d}');
			text += ',' + this.$htmlRegx(this.infoDetail.content);
			this.$tts(text, this, 500);
		}
	}
};
</script>

<style lang="scss">
.detail-view {
	background-color: #fff;
}

.fiexd-btm {
	position: static;
	border-top: 10rpx solid $u-border-color;
	padding: 30rpx;
}
</style>
